package com.ruoyi.system.controller;

import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.utils.StringUtils;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.web.page.TableDataInfo;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.InnerAuth;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.system.domain.BaseShop;
import com.ruoyi.system.domain.BaseShopUser;
import com.ruoyi.system.service.IBaseShopUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 【请填写功能名称】Controller
 *
 * @author ruoyi
 * @date 2022-09-30
 */
@RestController
@RequestMapping("/shopuser")
public class BaseShopUserController extends BaseController
{
    @Autowired
    private IBaseShopUserService baseShopUserService;

    /**
     * 查询【请填写功能名称】列表
     */
    @RequiresPermissions("system:user:list")
    @GetMapping("/list")
    public TableDataInfo list(BaseShopUser baseShopUser)
    {
        startPage();
        List<BaseShopUser> list = baseShopUserService.selectBaseShopUserList(baseShopUser);
        return getDataTable(list);
    }

    /**
     * 导出【请填写功能名称】列表
     */
    @RequiresPermissions("system:user:export")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BaseShopUser baseShopUser)
    {
        List<BaseShopUser> list = baseShopUserService.selectBaseShopUserList(baseShopUser);
        ExcelUtil<BaseShopUser> util = new ExcelUtil<BaseShopUser>(BaseShopUser.class);
        util.exportExcel(response, list, "【请填写功能名称】数据");
    }

    /**
     * 获取【请填写功能名称】详细信息
     */
    @RequiresPermissions("system:user:query")
    @GetMapping(value = "/{userId}")
    public AjaxResult getInfo(@PathVariable("userId") Long userId)
    {
        return AjaxResult.success(baseShopUserService.selectBaseShopUserByUserId(userId));
    }

    /**
     * 新增【请填写功能名称】
     */
    @RequiresPermissions("system:user:add")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BaseShopUser baseShopUser)
    {
        return toAjax(baseShopUserService.insertBaseShopUser(baseShopUser));
    }

    /**
     * 修改【请填写功能名称】
     */
    @RequiresPermissions("system:user:edit")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BaseShopUser baseShopUser)
    {
        return toAjax(baseShopUserService.updateBaseShopUser(baseShopUser));
    }

    /**
     * 删除【请填写功能名称】
     */
    @RequiresPermissions("system:user:remove")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.DELETE)
	@DeleteMapping("/{userIds}")
    public AjaxResult remove(@PathVariable Long[] userIds)
    {
        return toAjax(baseShopUserService.deleteBaseShopUserByUserIds(userIds));
    }


}
